Emplot



A clean theme for ggplot2 with matching geom defaults.

Examples

library(ggplot2)
library(emplot)
ggplot(mpg, aes(displ, hwy, color = class)) +
    geom_point()

ggplot(mpg, aes(displ)) +
    geom_histogram(bins = 30)

Options

The grid can be forced on/off with the grid option:

library(tidyverse)
library(gapminder)
as_tibble(gapminder) %>%
    mutate(cc = I(country_colors[match(country, names(country_colors))])) %>%
    filter(continent %in% c("Africa", "Europe") & year == 2007) %>%
    ggplot(aes(log(gdpPercap), lifeExp)) +
        geom_point(aes(colour = cc, size = sqrt(pop/pi)/1500)) +
        theme_emplot(grid = FALSE) +
        theme(legend.position = "none")

The font can be changed to a serif with the serif option (for the Tufte look):

ggplot(iris, aes(Petal.Length)) +
    geom_histogram(bins = 30) +
    scale_y_continuous(breaks = seq(5, 25, by = 5)) +
    geom_hline(yintercept = seq(5, 25, by = 5), col = "white") +
    theme_emplot(grid = FALSE, serif = TRUE)

library(tidyverse)
mpg %>%
    mutate(cyl = as.factor(cyl)) %>%
    ggplot(aes(displ, hwy, color = cyl)) +
        geom_point() +
        geom_smooth(method = lm, se = FALSE) +
        theme_emplot(grid = FALSE, serif = TRUE) +
        scale_color_grey(end = 0.75)
#> `geom_smooth()` using formula 'y ~ x'

You can also use theme_emtufte to reproduce the Tufte look out-of-the-box:

mtcars %>%
    ggplot(aes(disp, hp)) +
        geom_point() +
        theme_emtufte()